fix(agent): use tsup watcher for dev mode instead of tsx (fixes #253)#310
Merged
Conversation
Fixes #253. `tsx watch src/index.ts` has crashed at boot since Phase D: @bonfida/spl-name-service@3.0.21 ships a borsh ESM bundle that tsx's ESM loader cannot instantiate (plain Node handles it fine). Switch the agent dev script to `tsup --watch src --onSuccess 'node dist/index.js'`, matching the root pattern. tsup transpiles only the agent's own source and runs the output with plain node, sidestepping tsx's loader. skipNodeModulesBundle is required: bundling the transitive CJS chain (bs58 -> safe-buffer -> require("buffer")) into one ESM file otherwise fails with "Dynamic require of buffer is not supported". Verified: the agent boots past all imports to the normal SIPHER_NETWORK env check -- no borsh SyntaxError, no dynamic-require error. Production build (tsc) + start are unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #253. The agent's
devscript (tsx watch src/index.ts) has crashed at boot since Phase D because@bonfida/spl-name-service@3.0.21ships a borsh ESM bundle that tsx's ESM loader cannot instantiate (plain Node handles it fine).Fix
Switch
devto a tsup watcher matching the root pattern:dev→tsup --watch src --onSuccess 'node dist/index.js'packages/agent/tsup.config.ts(esm, node22,skipNodeModulesBundle: true)tsuptodevDependenciestsup transpiles only the agent's own source and runs the output with plain
node, sidestepping tsx's loader.skipNodeModulesBundle: trueis required — without it, tsup bundles the transitive CJS chain (bs58→safe-buffer→require("buffer")) into one ESM file and fails withDynamic require of "buffer" is not supported.Verification
pnpm exec tsupbuilds clean (368 KB);node dist/index.jsboots past all imports to the normal env validation (FATAL: SIPHER_NETWORK env var required) — confirming both the original borshSyntaxErrorand the dynamic-require error are gone.Production
build(tsc) +startare unchanged — this only touches dev mode.tsxis retained in devDependencies (may be used for ad-hoc scripts).